package base.domain;

import base.prototype.framework.Product;

/**
 * @program: DesignPatterns
 * @description: 打印矩形
 * @author: Mr.Dai
 * @create: 2018-05-28 21:38
 **/
public class Rectangle implements Product {

    private char mark = '*';

    public Rectangle(char mark) {
        this.mark = mark;
    }

    public Rectangle() {
    }

    @Override
    public void use(int len) {
        for (int i = 0; i < len; i++) {
            if(i==0||i==len-1){
                for (int k = 0; k < len; k++) System.out.print(mark);
            }else{
                System.out.print('*');
                for (int j = 0; j < len-2; j++) {
                    System.out.print(' ');
                }
                System.out.print('*');
            }
            System.out.println();
        }
    }

    @Override
    public Product createClone() {
        Product product = null;
        try {
            product = (Product) clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return product;
    }
}
